package com.example.userconsumer.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author likaiping
 * @createTime 2024/7/7 15:19
 */
//@Service
public class WebSocketSender {

//    @Resource
    private SimpMessagingTemplate simpMessagingTemplate;

    public void sendSeckillNotification(String message) {
        //将消息发送到 /topic/seckill 目的地，所有订阅该目的地的客户端将会收到消息
        simpMessagingTemplate.convertAndSend("/topic/seckill", message);
    }
}
